<template>
	<view class="view-main">
		<map :latitude="common.store.lat" :longitude="common.store.lng" scale="16" show-location
			style="width: 100%; height: 30vh;">
			<image class="map-marker" :src="markerIcon"></image>
		</map>
		<view class="page-con">
			<view class="con-hd">
				<view class="choose-address2">
					<view class="address2-l">
						<view class="address2-lhd">{{common.store.name}}</view>
						<view class="address2-lbd">{{common.store.address}}</view>
						<view class="address2-lbd">营业时间：{{common.store.business_hours}}</view>
					</view>
					<view class="address2-r">
						<image :src="$wanlshop.oss('/uploads/staticImage/restaurant/common/phone.png')" mode="widthFix" @tap="call"></image>
						<image src="/static/restaurant/common/address.png" mode="widthFix" @tap="chooseAddressView"></image>
					</view>
				</view>
			</view>
			<view class="con-bd">
				<swiper class="swiper" circular :indicator-dots="true" :autoplay="true" :interval="2000" :duration="500"
					style="height: 270rpx;margin-top: 30rpx;border-radius: 10rpx;overflow: hidden;">
					<swiper-item v-for="(item,index) in common.store.images_text" :key="index">
						<image :src="$wanlshop.oss(item)" class="topViewImg" mode="aspectFill">
						</image>
					</swiper-item>
				</swiper>
				<rich-text v-if="common.store && common.store.content" :nodes="common.store.content"></rich-text>
				
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				markerIcon: require('@/components/s-choose-address/static/marker.png'),

			}
		},
		onLoad(option) {
			uni.setNavigationBarTitle({
				title:this.common.store.name
			})
			this.loadData()
		},
		computed: {
			...mapState(['user', 'common'])
		},
		methods: {
			async loadData() {
				let res = await this.$api.getStore({
					storeid: this.common.store && this.common.store.id
				});
				if (res.code == 1) {
					if(res.data.content) {
						res.data.content = res.data.content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, (
							match, capture) => {
							var img =
								`<img style="display: block; max-width: 100%;" src="${this.$wanlshop.oss(capture)}">`;
							return img;
						});
					}
					this.$store.dispatch('common/setStore', res.data);
				}
			},
			call() {
				uni.makePhoneCall({
					phoneNumber: this.common.store.mobile
				});
			},
			chooseAddressView() {
				wx.openLocation({
					latitude: Number(this.common.store.lat), // 上海的纬度
					longitude: Number(this.common.store.lng), // 上海的经度
					name: this.common.store.name, // 地点名称
					address: this.common.store.address, // 地址的详细说明
					scale: 18, // 缩放比例
					success: function(res) {
						console.log('打开地图成功');
					},
					fail: function(err) {
						console.log('打开地图失败', err);
					}
				});
			
			},
		}
	}
</script>


<style lang="less" scoped>
	.view-main {
		width: 100%;
		background: #f3f3f3;
	}

	.topViewImg {
		border-radius: 10rpx;
		width: 702rpx;
		height: 270rpx;
	}

	.map-marker {
		width: 44rpx;
		height: 62rpx;
		position: absolute;
		top: 15vh;
		left: 50%;
		transform: translate(-50%, -50%);
	}

	.map-tip {
		font-size: 20rpx;
		color: #b6b6b6;
		line-height: 42rpx;
		padding: 0 20rpx;
		position: absolute;
		left: 50%;
		top: 30rpx;
		box-shadow: 0px 1px 10px 1px rgba(153, 153, 153, 0.34);
		background-color: #fff;
		border-radius: 4px;
		transform: translateX(-50%);
	}

	.poiss-box {
		width: 100%;
		padding: 20rpx 0;
		background-color: #FFFFFF;
		font-size: 26rpx;
		position: fixed;
		bottom: 0;
		left: 0;
	}

	.poiss-item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: calc(100% - 48rpx);
		height: 100rpx;
		padding: 0 24rpx;
		border-bottom: 1px solid #f9f9f9;
	}

	.poiss-item-l {
		width: calc(100% - 184rpx);
	}

	.poiss-item-lhd {
		font-size: 32rpx;
		color: #333333;
		line-height: 48rpx;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.poiss-item-lbd {
		font-size: 28rpx;
		color: #b6b6b6;
		line-height: 42rpx;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.poiss-item-r {
		width: 36rpx;
		height: 36rpx;
		margin: 0 30rpx;
	}

	.primary-btn {
		width: 688rpx;
		height: 88rpx;
		margin: 0 auto;
		margin-top: 28rpx;
		background: #FA802A;
		border-radius: 44rpx;
		font-size: 32rpx;
		color: #FFFFFF;
		line-height: 88rpx;
		text-align: center;
	}

	.page-con {
		width: 100%;
		// height: 75vh;
		// position: fixed;
		// bottom: 0;
		// left: 0;
		position: relative;
		z-index: 9;
		margin-top: -30rpx;
	}

	.con-hd {
		display: flex;
		align-items: center;
		width: 702rpx;
		height: 168rpx;
		margin: 0 auto;
		background: #FFFFFF;
		box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(88, 102, 123, 0.2);
		border-radius: 24rpx;
	}

	.choose-address {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 92%;
		height: 64rpx;
		margin: 0 auto;
		border-radius: 12rpx;
		border: 2rpx solid #FA802A;
		font-size: 32rpx;
		color: #FA802A;
	}

	.choose-address2 {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		padding: 0 24rpx;
	}

	.address2-l {
		width: calc(100% - 184rpx);
	}

	.address2-lhd {
		font-size: 32rpx;
		font-weight: bold;
		color: #333333;
		line-height: 48rpx;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.address2-lbd {
		font-size: 28rpx;
		color: #999999;
		line-height: 42rpx;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.address2-r {
		// width: 144rpx;
		// height: 60rpx;
		// background: #FFFFFF;
		// border-radius: 12rpx;
		// border: 2rpx solid #FA802A;
		// font-size: 28rpx;
		// color: #FA802A;
		// line-height: 60rpx;
		// text-align: center;
		
		
		position: relative;
	
		&::after {
			position: absolute;
			content: "";
			display: inline-block;
			width: 1px;
			height: 50rpx;
			background-color: #E3E3E3;
			left: 76rpx;
			top: 0;
		}
	
		image {
			width: 50rpx;
			height: 50rpx;
	
			&:nth-child(1) {
				margin-right: 26rpx;
			}
	
			&:nth-child(2) {
				margin-left: 26rpx;
			}
		}
	}

	.con-bd {
		width: 100%;
		padding: 0 26rpx;
		margin-top: 24rpx;
		background: #FFFFFF;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}
</style>